# -*- coding: utf-8 -*-
COLLAR_INTERVAL = 5 * 60
BARN_INTERVAL = 10 * 60
BASE_INTERVAL = 15 * 60


class Req:
    def __init__(self, funcId, time, req_type, sensorId):
        self.funcId = funcId
        self.start_timestamp = time
        self.end_timestamp = -1
        self.containerId = -1
        self.reqType = req_type
        self.isRejected = False
        self.fromSensorId = sensorId

        self.size = -1
        self.flop = -1
        self.interval = -1
        self.initConfig()

    def initConfig(self):
        value = self.reqType.value
        if 1000 < value < 2000:
            self.interval = COLLAR_INTERVAL
            if value == 1001:
                self.size = 60
            elif value == 1002:
                self.size = 90
            elif value == 1003:
                self.size = 120
            else:
                self.size = 150
            self.flop = self.size * 1
        elif 2000 < value < 3000:
            self.interval = BARN_INTERVAL
            if value == 2001:
                self.size = 100
            elif value == 2002:
                self.size = 200
            elif value == 2003:
                self.size = 300
            elif value == 2004:
                self.size = 400
            elif value == 2005:
                self.size = 500
            else:
                self.size = 600
            self.flop = self.size * 5
        else:
            self.interval = BASE_INTERVAL
            if value == 3001:
                self.size = 200
            elif value == 3002:
                self.size = 300
            elif value == 3003:
                self.size = 400
            elif value == 3004:
                self.size = 500
            elif value == 3005:
                self.size = 600
            elif value == 3006:
                self.size = 700
            else:
                self.size = 800
            self.flop = self.size * 7
